<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言板 - AACRBBS</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
    <div class="container">
        <h1>留言板</h1>
        <h2>AACRBBS</h2>

        <!-- 搜索功能 -->
        <div class="search">
            <form method="GET" action="/messageboard">
                <input type="text" name="search" placeholder="搜索帖子内容" value="{{ request.args.get('search', '') }}">
                <button type="submit">搜索</button>
            </form>
        </div>

        <!-- 发布帖子表单 -->
        <form method="POST" action="/messageboard">
            <label for="content">发布内容</label>
            <textarea name="content" id="content" required></textarea><br>
            <button type="submit">发布</button>
        </form>

        <!-- 帖子列表 -->
        <div class="posts">
            {% for post in posts %}
            <div class="post">
                {% set content_lines = post[2].split('\n') %}
                <h3>{{ post[1] }}: {{ content_lines[0] }}</h3>
                <p class="update">最后更新于 {{ post[4] }}</p>
                <a href="/p/{{ post[5] }}">查看帖子</a>
            </div>
            {% else %}
            <p>暂无帖子</p>
            {% endfor %}
        </div>
    </div>
</body>
</html>